const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

/*时间戳处理*/
function getzf(num) {
  if (parseInt(num) < 10) {
    num = '0' + num;
  }
  return num;
}
function getMyDate(str) {
  if (str == null) {
    var oTime = '--'
    return oTime;
  } else {
    var oDate = new Date(str), oYear = oDate.getFullYear(), oMonth = oDate.getMonth() + 1, oDay = oDate.getDate();
    var oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay);//最后拼接时间
    return oTime;
  }
  
}
/*号码及证件号加密*/
function personTel(Tel) {
  if (Tel==null){
    var phone = '--'
    return phone;
  }else{
    var phone = Tel.replace(Tel.substr(3, Tel.length - 7), '****');
    return phone;
  }
  
}
module.exports = {
  getMyDate: getMyDate,
  personTel: personTel,
}

